/**
 * XQuery to Scala Translator
 * Fatemeh Borran-Dejnabadi
 * 16 November 2004
 */

package xquery2src;

/** Class Tree defines the type of all abstract syntax tree nodes.
 */
class Tree {

  /** The source code position of this tree node.
   */

  /** The type of this tree node
   */
  var treeType:Type = null;

  var symbol:Symbol = null;

  /** The translation of this tree node
   */
  var translation:StringBuffer = new StringBuffer();

}

/** This node represents an erroneous syntactical construct.
 */
case class Bad(pos:int) extends Tree;

/** Q = XMLExpr ident {A} Q
 */
case class XMLExpr(pos:int, tag:String, attrExpr:Array[Tree], content:Tree) extends Tree;

/** A = AttrExpr ident S
 */
case class AttrExpr(pos:int, att:String, value:Tree) extends Tree;

/** E = Sequence {S}
 */
case class Sequence(pos:int, singleExprs:Array[Tree]) extends Tree;

/** S = Flwor {K} E {O} S
 */
case class Flwor(pos:int, types:Array[Tree], wExpr:Sequence, oExprs:Array[Tree], rExpr:Tree) extends Tree;

/** K = For {V}
 */
case class For(pos:int, vars:Array[Tree]) extends Tree;

/** K = Let {V}
 */
case class Let(pos:int, vars:Array[Tree]) extends Tree;

/** S = Some {V} S
 */
case class Some(pos:int, vars:Array[Tree], satisfies:Tree) extends Tree;

/** S = Every {V} S
 */
case class Every(pos:int, vars:Array[Tree], satisfies:Tree) extends Tree;

/** V = Var ident S
 */
case class Var(pos:int, ident:String, domain:Tree) extends Tree;

/** S = If E S S
 */
case class If(pos:int, cond:Sequence, thenIf:Tree, elseIf:Tree) extends Tree;

/** S = BinOp O2 P P
 */
case class BinOp(pos:int, operation:int, operand1:Tree, operand2:Tree) extends Tree;

/** S = UniOp O1 P
 */
case class UniOp(pos:int, operation:int, operand:Tree) extends Tree;

/** O = OrderBy S O4
 */
case class OrderBy(pos:int, orderBy:Tree, order:String) extends Tree;

/** P = UniOp O3 R
 *  R = BinOp O3 F F
 *  F = Filter T {E}
 */
case class Filter(pos:int, expr:Tree, preds:Array[Tree]) extends Tree;

/** T = Int number
 */
case class IntTree(pos:int, value:int) extends Tree;

/** T = String string
 */
case class StringTree(pos:int, string:String) extends Tree;

/** T = Element ident
 */
case class Element(pos:int, name:String) extends Tree;

/** T = Attribute ident
 */
case class Attribute(pos:int, name:String) extends Tree;

/** T = Ident ident
 */
case class Ident(pos:int, name:String) extends Tree;

/** T = Expr E
 */
case class Expr(pos:int, expr:Sequence) extends Tree;

/** T = FunCall C {S}
 */
case class FunCall(pos:int, fname:int, args:Array[Tree]) extends Tree;
